package coba.mailing.query;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import coba.mailing.model.Itinerario;

public class FindItinerarioById {

	public static Itinerario find(Connection con, Long institucionId) throws SQLException {

		String sql = " select * from COBA_Itinerarios i where id_ = ? ";

		PreparedStatement stmt = con.prepareStatement(sql);

		stmt.setLong(1, institucionId);

		ResultSet rs = stmt.executeQuery();

		Itinerario itinerario = null;

		if (rs.next()) {
			itinerario = new Itinerario(
					rs.getLong("i.id_"),
					rs.getString("i.nombre"));
		}

		rs.close();
		stmt.close();

		return itinerario;

	}

}
